#ifndef __HI_VIDEO_VPROC_H__
#define __HI_VIDEO_VPROC_H__

#include "hi_type.h"
#include "hi_comm_video.h"

#define HI_VIDEO_VORC_IMG_ADDR_NUM 3

typedef enum {
    IMAGE_TYPE_BGR = 1 << 1,
    IMAGE_TYPE_YVU420SP = 1 << 2,
    IMAGE_TYPE_YVU422SP = 1 << 3,
    IMAGE_TYPE_BUTT
}ImageDataType;


typedef struct {
    HI_U64 virAddr[HI_VIDEO_VORC_IMG_ADDR_NUM];
    HI_U64 phyAddr[HI_VIDEO_VORC_IMG_ADDR_NUM];
    HI_U32 stride[HI_VIDEO_VORC_IMG_ADDR_NUM];
    HI_U32 width;
    HI_U32 height;
    HI_U64 imgPts;
    ImageDataType imageType;
    HI_U32 poolId;
} HiImage;

class HiVprocPortParam {
public:
    HiVprocPortParam() {
        srcFrameRate = -1;
        dstFrameRate = -1;
        width = 0;
        height = 0;
    }

    ~HiVprocPortParam(){}

    HI_S32 srcFrameRate;
    HI_S32 dstFrameRate;
    HI_S32 width;
    HI_S32 height;
};

class HiVideoVproc {
public:

    HiVideoVproc();
    HiVideoVproc(HI_S32 width, HI_S32 height);
    virtual ~HiVideoVproc();

    HI_S32 GetFrame(HI_HANDLE grpHdl, HI_HANDLE portHdl,HiImage& image);
    HI_S32 ReleaseFrame(HI_HANDLE grpHdl, HI_HANDLE portHdl,HiImage& image);
    HI_S32 SendFrame(HI_HANDLE vpssHdl ,HiImage& image);

    HI_S32 StartPort(HI_HANDLE vpssHdl, HI_HANDLE portHdl);
    HI_S32 StopPort(HI_HANDLE vpssHdl, HI_HANDLE portHdl);
    HI_S32 StartDumpPort(HI_HANDLE vpssHdl, HI_HANDLE portHdl, const HiVprocPortParam& portParam = HiVprocPortParam());

    HI_S32 ResizeImg(HiImage& inImage, HiImage& outImage);
    HI_S32 SendYUVPic(HiImage& image);
    HI_S32 ReleaseBuffer(HI_U64 phyAddr, HI_VOID* virAddr);
    HI_S32 AcquireBuffer(HI_U32 height, HI_U32 width, ImageDataType imageType, HI_U64* phyAddr, HI_VOID** virAddr);
    ImageDataType GetImageType(const PIXEL_FORMAT_E pixelFormat);
private:
    HI_VOID* m_image;
    HI_U32 m_width;
    HI_U32 m_height;
    HI_U32 m_size;
    HI_U32 m_pool;
};

#endif //__HI_VIDEO_ENCODER_H__
